#include <ros/ros.h>
#include <std_msgs/String.h>
// #include <geometry_msgs/Twist.h>

void read_serial_cmd(std_msgs::String msg)
{
  ROS_INFO("\n get data:%s\n", msg.data.c_str());
}
void write_serial_cmd(std_msgs::String msg)
{
  ROS_WARN("\n ma:%s\n", msg.data.c_str());
}

int main(int argc, char *argv[])
{
  ros::init(argc, argv, "base_node");
  // ROS_INFO("\n base_node %s,%s!\n", __DATE__, __TIME__);
  ros::NodeHandle nh;

  // process serial data
  // ros::Subscriber sub = nh.subscribe("/serial_read", 10, read_serial_cmd);

  // send move cmd
  //  ros::Publisher vel_pub = nh.advertise<geometry_msgs::Twist>("/serial_write", 10);
  //  geometry_msgs::Twist vel_msg;
  //  vel_msg.linear.x = 0.1;
  //  vel_msg.linear.y = 0.0;
  //  vel_msg.linear.z = 0.0;
  //  vel_msg.angular.x = 0;
  //  vel_msg.angular.y = 0;
  //  vel_msg.angular.z = 0;
  //  ros::Rate r(30);

  // while (ros::ok)
  // {
  //     vel_pub.publish(vel_msg);
  //     r.sleep();
  // }
  ros::Publisher pub = nh.advertise<std_msgs::String>("/serial_write", 10);
  ros::Rate loop_rate(1);
  while (ros::ok())
  {
    // ROS_INFO(" qq show!\n");
    std_msgs::String msg;
    msg.data = "send cmd data";
    // ros::Rate loop_rate(1000);
    pub.publish(msg);
    ros::spinOnce();
    loop_rate.sleep();
  }

  return 0;
}
